// pages/User/index.js
Page({
    data: {
        commodity: null,
        uid: null,
        tools_services: null,

    },
    all_orders: function (e) {
        wx.navigateTo({
            url: '/pages/allOrders/index?uid=' + this.data.uid,
        })
    },
    log_out: function (e) {

        wx.clearStorage();
        wx.reLaunch({
            url: '/pages/User/index',
        })
    },
    onLoad: function () {
        wx.getStorage({
            key: "user",
            success: (res) => {
                let u_email = res.data.u_email;
                let u_password = res.data.u_password;
                let uid = res.data.uid;
                let u_collection = res.data.u_collection;
                let u_shop = res.data.u_shop;
                let u_history = res.data.u_history;
                let u_name = res.data.u_name;
                let u_pic = res.data.u_pic

                this.setData({
                    u_email,
                    u_password,
                    uid,
                    u_collection,
                    u_shop,
                    u_history,
                    u_name,
                    u_pic
                });
            }
        });
        wx.getStorage({
            key: "property",
            success: (res) => {
                let discount_coupon = res.data[0];
                let balance = res.data[1];
                let jingdou = res.data[2];
                let red_packet = res.data[3];

                this.setData({
                    discount_coupon,
                    balance,
                    jingdou,
                    red_packet
                });
            }
        })
        wx.request({
            url: 'http://460d80b632.zicp.vip/WeChat/kill.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {

                let commodity = res.data;
                this.setData({
                    commodity
                });
            }
        });
        wx.request({
            url: 'http://460d80b632.zicp.vip/WeChat/userPage.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                let tools_services = res.data;
                this.setData({
                    tools_services
                });
            }
        })
    },
    onShow: function (options) {
        if (this.data.uid != null) {
            wx.request({
                // 标题
                url: 'http://460d80b632.zicp.vip/WeChat/getUser.php',
                method: "POST",
                data: {
                    "uid": this.data.uid,
                },
                header: {
                    "Content-Type": "application/x-www-form-urlencoded"
                },
                success: (res) => {

                    let u_collection = res.data[0].u_collection;
                    let u_shop = res.data[0].u_shop;
                    let u_history = res.data[0].u_history;

                    this.setData({
                        u_collection,
                        u_shop,
                        u_history,
                    });
                }
            });
        }

    },


})